import request from '@/utils/request';

export async function querySmtpList(page_num, page_size) {
  return request(`/api/gold/system_email_list?page_num=${page_num}&page_size=${page_size}`, {
    page_num,
    page_size,
  });
}

export async function queryRelatedUser() {
  return request(`/api/gold/relation_user_info`, {});
}

export async function addSmtpEntry(name, email_server, email, password, relation_account_id) {
  return request(`/api/gold/system_email_create`, {
    method: 'POST',
    body: {
      name,
      email_server,
      email,
      password,
      relation_account_id: relation_account_id.join(','),
    },
  });
}

export async function updateSmtpEntry(
  id,
  name,
  email_server,
  email,
  password,
  relation_account_id
) {
  return request(`/api/gold/system_email_update`, {
    method: 'POST',
    body: {
      id,
      name,
      email_server,
      email,
      password,
      relation_account_id: relation_account_id.join(','),
    },
  });
}

export async function deleteSmtpEntry(id) {
  return request(`/api/gold/system_email_delete`, {
    method: 'POST',
    body: {
      id,
    },
  });
}
